// 列表头按钮配置
import url from "@/axios/url";

const { mesUrl} = url();
export const exportUrl = `${mesUrl}quote/export`

export const exportExlUrl = `${mesUrl}quote/exportExl/`;


export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl,
    //auth: "auth:operlog:export", //权限字段
  },
  {
    name: $i18n.t('common.delete'),
    type: 'danger',
    icon: 'el-icon-delete',
    handleName: 'deleteBatch', // 点击时返回的标识
    isMultiple: true
  },
]
// 行末按钮配置
export const rowConfig = [
  {
    name: '编辑',
    type: 'primary',
    class: 'row-btn-primary',
    handleName: 'edit' // 点击时返回的标识
  },
  {
    name: '导出',
    type: 'primary',
    class: 'row-btn-primary',
    handleName: 'exportExl', // 点击时返回的标识,
  },
  {
    name: '打印',
    type: 'primary',
    class: 'row-btn-primary',
    handleName: 'print' // 点击时返回的标识
  },
  {
    name: $i18n.t('common.delete'),
    type: 'danger',
    class: 'row-btn-danger',
    handleName: 'delete' // 点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  data() {
    const self = this
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          orderCode: {
            type: 'input',
            label: '编号'
          },
          vinCode: {
            type: 'input',
            label: 'VIN'
          },
          modelName: {
            type: 'input',
            label: '车型'
          },
          // quoteState: {
          //   type: 'select',
          //   label: '状态',
          //   options: (data) => {
          //     return [
          //       {
          //         text: "未创建",
          //         value: '-1'
          //       },
          //       {
          //         text: "草稿",
          //         value: '0'
          //       },
          //       {
          //         text: "推送",
          //         value: '1'
          //       },
          //       {
          //         text: "确认",
          //         value: '2'
          //       },
          //     ]
          //   }
          // },
          pushState: {
            type: 'select',
            label: '推送状态',
            options: (data) => {
              return [
                {
                  text: "未推送",
                  value: '0'
                },
                {
                  text: "部分推送",
                  value: '1'
                },
                {
                  text: "全部推送",
                  value: '2'
                },
              ]
            }
          },
          confimState: {
            type: 'select',
            label: '确认状态',
            options: (data) => {
              return [
                {
                  text: "未确认",
                  value: '0'
                },
                {
                  text: "部分确认",
                  value: '1'
                },
                {
                  text: "全部确认",
                  value: '2'
                },
              ]
            }
          },
        }
      }
    }
  }
}
// 新增/删除表单配置
export const formDescDialogMixin = {
  data() {
    const self = this
    return {
      formDescDialog: {
        span: 24,
        labelPosition: 'top',
        formDesc: {
          customerName: {
            type: 'input',
            label: '客户名称',
            layout: 6,
            required: true
          },
          vehicleGuidePrice: {
            type: 'input',
            label: '新车指导价',
            layout: 6,
            attrs: { readonly: true }
          },
          // customerContact: {
          //   type: 'input',
          //   label: '客户联系人',
          //   layout: 6,
          //   required: true
          // },
          // customerPhone: {
          //   type: 'input',
          //   label: '客户联系电话',
          //   layout: 6,
          //   required: true
          // },
          orderCode: {
            type: 'input',
            label: '订单编号',
            layout: 6,
            attrs: { readonly: true }
          },
          modelName: {
            type: 'input',
            label: '车型',
            layout: 6,
            attrs: { readonly: true }
          },
          modelColor: {
            type: 'input',
            label: '车身颜色',
            layout: 6,
            attrs: { readonly: true }
          },
          vinCode: {
            type: 'input',
            label: 'VIN码',
            layout: 6,
            attrs: { readonly: true }
          },
          mileage: {
            type: 'input',
            label: '里程数(km)',
            layout: 6,
            attrs: { readonly: true }
          },
          vehicleRegisterDate: {
            type: 'input',
            label: '首次上牌日期',
            layout: 6,
            attrs: { readonly: true }
          },
          quoteHours: {
            type: 'input',
            label: '工时总报价',
            layout: 8,
            attrs: { readonly: true }
          },
          quoteItems: {
            type: 'input',
            label: '物料总报价',
            layout: 8,
            attrs: { readonly: true }
          },
          quoteExtra: {
            type: 'input',
            label: '固定项总报价',
            layout: 8,
            attrs: { readonly: true }
          },
          // estPrice: {
          //   type: 'input',
          //   label: '预估整备费用',
          //   layout: 6,
          //   attrs: { readonly: true }
          // },
          repairList: {
            label: '维修项目费用',
            layout: 24,
            required: true,
            type: 'table-editor',
            attrs: {
              // // 上方,按钮,render
              topBtnRender: (h, solt) => {
                return (
                  <el-button
                    type="primary"
                    onClick={() => {
                      self.doRepairSelectAll()
                    }}>
                    全选
                  </el-button>
                )
              },
              // 校检规则
              rules: {
                repairItem: { required: true, message: '请选择维修项目' },
                repairQuote: { required: true, message: '请输入工时报价' },
                itemCount: { required: true, message: '请输入部件数量' },
                itemQuote: { required: true, message: '请输入部件报价' }
              },
              isShowDelete:false,
              isShowAdd: false,
              extraBtns: [
                {
                  text: "查看图片",
                  attrs: {
                    type: "text",
                  },
                  style: {
                    color: '#6caaf5'
                  },
                  click(scope) {
                    self.viewPic(scope.row.photoUrl)
                  }
                },
              ],
              // 表格列
              //   字段已对完
              columns: [
                {
                  // el-table-column 的属性
                  label: '序号',
                  type: 'index',
                  width: 50
                },
                {
                  prop: 'isPush',
                  fixed: 'left',
                  label: '推送',
                  width: 50,
                  content: {
                    // type 可以为全局注册的组件名或者组件引用
                    type: 'el-checkbox',
                    attrs: ({ row }) => {
                      return {
                        trueLabel:'Y',falseLabel:'N',
                        disabled: row.isPushOg === "Y" ,
                      };
                    },
                  }
                },
                {
                  prop: 'partsName',
                  label: '部件',
                  minWidth: 80,
                  showOverflowTooltip: true
                },
                {
                  prop: 'descConcat',
                  label: '部件描述',
                  minWidth: 80,
                  showOverflowTooltip: true
                },
                {
                  prop: 'repairItem',
                  label: '维修项目',
                  minWidth: 80,
                  showOverflowTooltip: true
                },
                {
                  prop: 'repairQuote',
                  label: '工时报价(元)',
                  minWidth: 80,
                  content: {
                    on: {
                      change: (row) => {
                        self.updateTotalhour()
                      },
                    },
                    // type 可以为全局注册的组件名或者组件引用
                    type: 'el-input-number',
                    // attrs 是组件的属性
                    attrs: ({ row }) => {
                      return {
                        placeholder: '请输入工时报价',
                        min: 0,
                        controlsPosition: 'right',
                        disabled: row.isPushOg === "Y" ,
                      };
                    },
                  }
                },
                {
                  prop: 'itemName',
                  label: '物料名称',
                  minWidth: 160,
                  content: {
                    // type 可以为全局注册的组件名或者组件引用
                    type: 'el-input',
                    // attrs 是组件的属性
                    attrs: ({ row }) => {
                      return {
                        placeholder: '请输入物料名称',
                        controlsPosition: 'right',
                        disabled: row.isPushOg === "Y" ,
                      };
                    },
                  }
                },
                {
                  prop: 'state',
                  label: '物料状态',
                  minWidth: 80,
                },
                {
                  prop: 'materialType',
                  label: '物料品质',
                  minWidth: 80,
                },
                {
                  prop: 'itemCount',
                  label: '物料数量',
                  minWidth: 80,
                  content: {
                    // type 可以为全局注册的组件名或者组件引用
                    type: 'el-input-number',
                    // attrs 是组件的属性
                    attrs: ({ row }) => {
                      return {
                        placeholder: '请输入物料数量',
                        min: 0,
                        controlsPosition: 'right',
                        disabled: true ,
                      };
                    },
                  }
                },
                {
                  prop: 'countUnitShow',
                  label: '物料单位',
                  minWidth: 80,
                },
                {
                  prop: 'unitPrice',
                  label: '成本价',
                  minWidth: 80,
                },
                {
                  prop: 'unitPriceJc',
                  label: '加成价',
                  minWidth: 80,
                },
                {
                  prop: 'itemQuote',
                  label: '物料报价(元)',
                  minWidth: 80,
                  content: {
                    // type 可以为全局注册的组件名或者组件引用
                    type: 'el-input-number',
                    on: {
                      change: (row) => {
                        self.updateTotalitem()
                      },
                    },
                    attrs: ({ row }) => {
                      return {
                        placeholder: '请输入物料报价',
                        min: 0,
                        controlsPosition: 'right',
                        disabled: row.isPushOg === "Y" ,
                      };
                    },
                  }
                }
              ],

              // 新行默认值
              newColumnValue: {
                lineNum: 0,
                count: 0
              }
            }
          },
          extraList: {
            label: '固定收费项目',
            layout: 24,
            required: true,
            type: 'table-editor',
            attrs: {
              rules: {
                extraQuote: { required: true, message: '请输入项目报价' },
                extraQuoteRate: { required: true, message: '请输入项目费率' },
                extraQuoteCoef: { required: true, message: '请输入项目系数' }
              },
              topBtnRender: (h, solt) => {
                return (
                  <el-button
                    type="primary"
                    onClick={() => {
                      self.doExtraSelectAll()
                    }}>
                    全选
                  </el-button>
                )
              },
              isShowAdd: false,
              isShowDelete: false,
              columns: [
                {
                  prop: 'isPush',
                  fixed: 'left',
                  label: '推送',
                  width: 50,
                  content: {
                    // type 可以为全局注册的组件名或者组件引用
                    type: 'el-checkbox',
                    attrs: ({ row }) => {
                      return {
                        trueLabel:'Y',falseLabel:'N',
                        disabled: row.isPushOg === "Y" ,
                      };
                    },
                  }
                },
                {
                  // el-table-column 的属性
                  label: '序号',
                  type: 'index',
                  width: 50
                },
                {
                  prop: 'extraName',
                  label: '项目',
                  showOverflowTooltip: true
                },
                {
                  prop: 'extraQuoteCoef',
                  label: '系数(%)',
                  content: {
                    // type 可以为全局注册的组件名或者组件引用
                    type: 'el-input-number',
                    // attrs 是组件的属性
                    attrs: ({ row }) => {
                      return {
                        placeholder: '请输入系数',
                        min: 0,
                        controlsPosition: 'right',
                        disabled: row.isPushOg === "Y" ,
                      };
                    },
                    on: {
                      change: (row) => {
                        self.updateExtraList()
                      },
                    },
                  }
                },
                {
                  prop: 'extraQuoteRate',
                  label: '费率(%)',
                  content: {
                    on: {
                      change: (row) => {
                        self.updateExtraList()
                      },
                    },
                    // type 可以为全局注册的组件名或者组件引用
                    type: 'el-input-number',
                    // attrs 是组件的属性
                    attrs: ({ row }) => {
                      return {
                        placeholder: '请输入费率',
                        min: 0,
                        controlsPosition: 'right',
                        disabled: row.isPushOg === "Y" ,
                      };
                    },
                  }
                },
                {
                  prop: 'extraQuote',
                  label: '价格(元)',
                  content: {
                    // type 可以为全局注册的组件名或者组件引用
                    type: 'el-input-number',
                    // attrs 是组件的属性
                    change: (row) => {
                      self.updateTotalextra()
                    },
                    attrs: ({ row }) => {
                      return {
                        readonly: true,
                        placeholder: '请输入项目报价',
                        min: 0,
                        controlsPosition: 'right',
                        disabled: row.isPushOg === "Y" ,
                      };
                    },
                  }
                }
              ],

              // 新行默认值
              newColumnValue: {
                lineNum: 0,
                count: 0
              }
            }
          },
          mark: {
            type: 'textarea',
            label: '备注',
            layout: 24
          }
        }
      }
    }
  }
}
